#include "read_options.h"
namespace po = boost::program_options;
using std::vector;
using std::string;

#include <boost/format.hpp>
using boost::format;
#include "glob_files.h"
using glob_files::glob_expand;



bool read_options(prog_options& opt, int argc, char *argv[])
{
	opt.mandatory.add_options()

	// 
	//	single input file
	// 
	//("input_file,i",po::value<string>(&opt.input_file)
	//		//->set_name("FILE"),
	//		,"Input file " )

	("input_file,i",po::value<vector<string> >(&opt.input_filenames)
	 //->set_name("FILE"),
	 ,"Input file name or glob pattern." )
	("output_file,o",po::value<string>(&opt.output_filename)
	 //->set_name("FILE"),
	 ,"Output file name." );


	//opt.optional.add_options()
	//// 
	////  EXAMPLES
	//// 
	//("boolean_option,B",po::value<bool>(&opt.boolean_option)
	// ->zero_tokens()
	// ,"EXAMPLE OPTION.")
	//("unsigned_option,U",po::value<unsigned>(&opt.unsigned_option)
	// //->set_name("FILE"),
	// ->default_value(7)
	// ,"EXAMPLE OPTION.");






	opt.config_file.add_options()
	("input_file,"              "i", po::value<vector<string>>	(&opt.input_filenames)  ) ;
	("output_file,"             "o", po::value<string>			(&opt.output_filename) ) ;



	if (!opt.process_command_line(argc, argv))
		return false;


	// expand glob
	opt.input_filenames             = glob_expand(opt.input_filenames);
	if (! opt.input_filenames.size())
		throw std::logic_error("No matching input files were found. Please check the glob patterns in --input_filenames");


	opt.verbose() << "\n\n";
	return true;
}


